package org.sapmentors.returns;

import java.io.IOException;
import java.util.ArrayList;

import javax.servlet.ServletOutputStream;
import javax.servlet.http.*;

import org.sapmentors.returns.material.Material;
import org.sapmentors.returns.material.QueryMaterial;
import com.google.appengine.api.xmpp.*;

@SuppressWarnings("serial")
public class SAP_Return_robotServlet extends HttpServlet {
	public void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws IOException {
		resp.setContentType("text/plain");
		resp.getWriter().println("Hello, world");
		QueryMaterial qm = new QueryMaterial();
		ArrayList<Material> list = qm.getMaterial("1171");
		for(Material mat : list){
			resp.getWriter().println(mat+"\n");
		}
		
		   
//		         //retrieve the service from the factory  
//		         XMPPService xmppService = XMPPServiceFactory.getXMPPService();  
//		   
//		         //specify who to chat with - JID is the "bare" XMPP address  
//		         String recipient = "dgr@masteringwave.com";  
//		         JID jid = new JID(recipient);  
//		  
//		         String msgBody = "Hi there!";  
//		   
//		         //send an initial invitation to chat before sending messages  
//		         xmppService.sendInvitation(jid);  
//		   
//		         //build the message - in this case, just plain text.  
//		         //XML is also supported  
//		        Message msg = new MessageBuilder().withRecipientJids(jid)  
//		                                           .withBody(msgBody).build();  
//		   
//		         //send off the message and check if things went well  
//		         SendResponse status = xmppService.sendMessage(msg);  
//		         if (status.getStatusMap().get(jid) ==  
//		                                   SendResponse.Status.SUCCESS) {  
//		        	 resp.getWriter().println("That apparently went well...");  
//		         } else {  
//		        	 resp.getWriter().println("Something went wrong..");  
//		             
//		         }  
		
	}
}
